﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace Jy123.Web.Friend
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class FriendUnchain : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                context.Response.Redirect("/");
            }
            int userID = int.Parse(strUserIdFromCookie);
            string msg = string.Empty;

            string strFriendID = context.Request["FriendUserID"];
            if (!string.IsNullOrEmpty(strFriendID))
            {
                int unchainStatus = 0;//解除是否成功，0为不成功
                Jy123.Model.User_Friend mFriend = new Jy123.Model.User_Friend();
                Jy123.BLL.User_Friend bllFriend = new Jy123.BLL.User_Friend();
                mFriend = bllFriend.GetModel(Convert.ToInt32(strFriendID));
                unchainStatus = new Jy123.BLL.User.Friend().delFriend(userID, Convert.ToInt32(strFriendID));
                if (unchainStatus > 0)
                {
                    msg = "解除关系成功,ok";
                }
                else
                {
                    msg = "解除关系失败,error";
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(msg);
            //context.Response.Redirect("/Friend/ListMain.aspx",true);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
